from apps.admin import db


# 新建表Role
class Admin(db.Model):
    __tablename__ = 'fa_admin' #表名
    id = db.Column(db.Integer, primary_key = True) # id字段, int 类型,主键
    username = db.Column(db.String(50), unique = True) # name字段, 字符串类型,唯一
    password = db.Column(db.String(32)) # 
    nickname = db.Column(db.String(50)) # 
    salt = db.Column(db.String(30)) # 
    mobile = db.Column(db.String(11)) # 
    avatar = db.Column(db.String(255)) # 
    loginip = db.Column(db.String(20)) # 
    status = db.Column(db.Integer) # 
    logintime = db.Column(db.Integer) # 
    token = db.Column(db.String(36)) # 
    createtime = db.Column(db.Integer) # 
    updatetime = db.Column(db.Integer) # 
    # users = db.relationship('User', backref = 'role', lazy = 'joined') # 外键关系
    
    def __init__(self, username, password, nickname, salt, mobile, avatar, status, loginip, logintime, token, createtime, updatetime):
        # self.id = id
        self.username = username
        self.password = password
        self.nickname = nickname
        self.salt = salt
        self.mobile = mobile
        self.avatar = avatar
        self.status = status
        self.loginip = loginip
        self.logintime = logintime
        self.token = token
        self.createtime = createtime
        self.updatetime = updatetime

    def __repr__(self): # 相当于toString
        return "id=%d,username=%s" %(self.id,self.username)